<script>
export default {
  name: "index",
  data() {
    return {
      name: '',
      form: {
        nickname: '',
        avatar_url: '',
        phone: '',
        sex: '',
        address: '',
        height: '',
        birth_date: '',
        desc: '',
        images: []
      },
      action: this.$baseUrl + '/api/upload/file',
      fileList: [],
      fileList2: [],
      sexList: [
        {
          text: '男'
        },
        {
          text: '女'
        },
      ],
      showSex: false,
      showDate: false,
      dateParams: {
        year: true,
        month: true,
        day: true,
      },
      defaultDate: [],
      show: true,
      loginForm: {
        phone: '',
        code: ''
      },
      seconds: 0,
      userInfo: null
    }
  },
  onLoad({ name, resume_id, joinId }) {
    this.userInfo = uni.getStorageSync('userInfo')
    this.name = name
    this.$api.getResumeDetail({
      id: resume_id
    }).then(res2 => {
      this.form = {
        ...res2,
        images: (res2.images || '').split(',').filter(item => item)
      }
    })
    console.log(this.userInfo)
    if (!this.userInfo) {
      return
    }
    this.$api.updatePostJoin({
      id: joinId,
      userId: this.userInfo.id
    })

  },
  methods: {
    toTel() {
      uni.makePhoneCall({
        phoneNumber: this.form.phone
      });
    },
    sexCallback(index) {
      console.log(index)
      this.form.sex = this.sexList[index].text;
    },
    dateCallback(e) {
      console.log(e)
    },
    toView(index, list) {
      uni.previewImage({
        urls: list,
        current: index
      })
    },
  }
}
</script>

<template>
  <div class="detail3">
    <u-navbar title="简历详情" :background="{ backgroundColor: 'transparent'}" title-color="#000" :border-bottom="false"></u-navbar>
    <div class="top"></div>
    <div class="card">
      <u-form :model="form" ref="uForm" label-width="100px" label-position="top">
        <u-form-item label="投递职位"><u-input v-model="name" disabled/></u-form-item>
        <u-form-item label="头像" label-position="left">
          <div style="display: flex;justify-content: flex-end;width: 100%">
            <div style="display: flex;align-items: center;justify-content: center;width: 112rpx;height: 112rpx;border-radius: 50%;overflow:hidden;border: 1px solid #f2f2f2;background-color: #f2f2f2">
              <u-image height="100%" style="text-align: center" mode="heightFix" :src="form.avatar_url" @click="toView(0,[form.avatar_url])"></u-image>
            </div>
          </div>
        </u-form-item>
        <u-form-item label="姓名"><u-input v-model="form.nickname" disabled/></u-form-item>
        <u-form-item label="电话"><u-input v-model="form.phone" disabled/></u-form-item>
        <u-form-item label="性别"><u-input v-model="form.sex" disabled/></u-form-item>
        <u-form-item label="籍贯"><u-input v-model="form.address" disabled/></u-form-item>
        <u-form-item label="身高"><u-input v-model="form.height" type="digit" disabled/></u-form-item>
        <u-form-item label="生日"><u-input v-model="form.birthday" disabled/></u-form-item>
        <u-form-item label="自我评价"><u-input type="textarea" :auto-height="true" v-model="form.desc" disabled/></u-form-item>
        <u-form-item label="个人风采">
          <div style="display: flex;flex-wrap: wrap;width: 100%">
            <div
                v-for="(item,index) in form.images"
                @click="toView(index, form.images)"
                style="margin: 12rpx;display: flex;align-items: center;justify-content: center;width: 200rpx;height: 200rpx;overflow:hidden;border: 1px solid #f2f2f2;background-color: #f2f2f2">
              <u-image height="100%" style="text-align: center" mode="heightFix" :src="item"></u-image>
            </div>
          </div>
        </u-form-item>
      </u-form>

    </div>
    <div class="footer">
      <div class="button" @click="toTel">电话联系</div>
    </div>

    <u-action-sheet :list="sexList" v-model="showSex" @click="sexCallback"></u-action-sheet>
    <u-picker mode="time" v-model="showDate" :params="dateParams" @cancel="showDate = false" @confirm="dateCallback"></u-picker>
  </div>
</template>

<style scoped lang="scss">
.detail3 {
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 40rpx 24rpx 160rpx 24rpx;
  .login-box {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 660rpx;
    background-image: url("/static/resume/login_bg.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    z-index: 99;
    .form-item {
      padding: 0 36rpx;
      background-color: #ffffff;
      color: #000000;
      flex-grow: 1;
      margin:60rpx 0;
      text-align: center;
      line-height: 100rpx;
      height: 100rpx;
      border-radius: 50rpx;
      display: flex;
      align-items: center;
      padding: 0 60rpx;
      .send-btn  {
        color: #05C8CE;
        font-size: 28rpx;
        flex-shrink: 0;
      }
      input {
        border: none;
        outline: none;
        flex-grow: 1;
        font-size: 28rpx;
        color: #000000;
        text-align: left;
      }
    }
    .button {
      margin: 0;
      height: 100rpx;
      line-height: 100rpx;
      border-radius: 50rpx;
    }
    .close {
      position: absolute;
      right: 56rpx;
      top: 56rpx;
      width: 32rpx;
      height: 32rpx;
    }
    padding: 100rpx 56rpx;
  }
  .footer {
    background-color: #ffffff;
    border-bottom-left-radius: 16rpx;
    border-bottom-right-radius: 16rpx;
    display: flex;
    align-items: center;
    padding-bottom: 40rpx;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 2;
    left: 0;
    padding-top: 30rpx;
  }
  .button {
    flex: 1;
    margin: 0 30rpx;
    text-align: center;
    line-height: 80rpx;
    height: 80rpx;
    border-radius: 40rpx;
  }
  .card {
    position: relative;
    z-index: 2;
    background-color: #ffffff;
    border-radius: 16rpx;
    padding: 32rpx;
    overflow: auto;
    .card-header {
      height: 178rpx;
      display: flex;
      align-items: center;
      border: 1rpx solid #DADADA;
      .line {
        width: 8rpx;
        height: 54rpx;
        background-color: #05C8CE;
        border-radius: 3rpx 3rpx 3rpx 3rpx;
      }
      .title {
        height: 90rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: 600;
        font-size: 64rpx;
        color: #303030;
        line-height: 75rpx;
        text-align: center;
        font-style: normal;
        text-transform: none;
        flex-grow: 1;
      }
      // 工资
      .salary {
        height: 36rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: 600;
        font-size: 32rpx;
        color: #05C8CE;
        line-height: 36rpx;
        text-align: left;
        font-style: normal;
        text-transform: none;
        margin-left: 30rpx;
        margin-right: 30rpx;
      }

    }
    .card-body {
      .item {
        margin: 50rpx;
        .item-title {
          height: 44rpx;
          font-family: PingFang SC, PingFang SC;
          font-weight: 600;
          font-size: 32rpx;
          color: #303030;
          line-height: 38rpx;
          text-align: left;
          font-style: normal;
          text-transform: none;
          position: relative;
          margin-bottom: 20rpx;
          .title-icon {
            width: 24rpx;
            height: 24rpx;
            position: absolute;
            left: -6rpx;
            bottom: 0rpx;
          }
        }
      }
      .content {
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 24rpx;
        color: #3D3D3D;
        line-height: 36rpx;
        text-align: left;
        font-style: normal;
        text-transform: none;
        margin-bottom: 30rpx;
      }
    }
  }
  .top {
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    height: 522rpx;
    background: linear-gradient( 180deg, #05C8CE 0%, rgba(223,254,255,0.5) 100%);
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }
}
</style>
